home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / regicon / frmregs5.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-05-07  |  20.2 KB  |  618 lines

  1. VERSION 5.00
  2. Object = "{6B1BE80A-567F-11D1-B652-0060976C699F}#1.1#0"; "Regicon.ocx"
  3. Begin VB.Form Form1 
  4.    Caption         =   "RegiCon Test"
  5.    ClientHeight    =   6765
  6.    ClientLeft      =   2865
  7.    ClientTop       =   1995
  8.    ClientWidth     =   7365
  9.    LinkTopic       =   "Form1"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   6765
  12.    ScaleWidth      =   7365
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.ListBox List2 
  15.       Height          =   1230
  16.       Left            =   1200
  17.       TabIndex        =   32
  18.       Top             =   5400
  19.       Width           =   3975
  20.    End
  21.    Begin VB.ListBox List1 
  22.       Height          =   1230
  23.       Left            =   1200
  24.       TabIndex        =   31
  25.       Top             =   4080
  26.       Width           =   3975
  27.    End
  28.    Begin VB.CommandButton cmdEnumEntry 
  29.       Caption         =   "Enumerate Entry"
  30.       Height          =   375
  31.       Left            =   5400
  32.       TabIndex        =   17
  33.       Top             =   1200
  34.       Width           =   1815
  35.    End
  36.    Begin VB.CommandButton cmdIsKey 
  37.       Caption         =   "Does Key Exist?"
  38.       Height          =   375
  39.       Left            =   5400
  40.       TabIndex        =   16
  41.       Top             =   840
  42.       Width           =   1815
  43.    End
  44.    Begin VB.CommandButton cmdExit 
  45.       Caption         =   "Exit"
  46.       Height          =   375
  47.       Left            =   5400
  48.       TabIndex        =   22
  49.       Top             =   3240
  50.       Width           =   1815
  51.    End
  52.    Begin VB.CommandButton cmdIsItem 
  53.       Caption         =   "Does Item Exist?"
  54.       Height          =   375
  55.       Left            =   5400
  56.       TabIndex        =   21
  57.       Top             =   2760
  58.       Width           =   1815
  59.    End
  60.    Begin VB.CommandButton cmdDeleteKeyItem 
  61.       Caption         =   "Delete Item"
  62.       Height          =   375
  63.       Left            =   5400
  64.       TabIndex        =   20
  65.       Top             =   2400
  66.       Width           =   1815
  67.    End
  68.    Begin VB.CommandButton cmdGetKeyItem 
  69.       Caption         =   "Get Item"
  70.       Height          =   375
  71.       Left            =   5400
  72.       TabIndex        =   19
  73.       Top             =   2040
  74.       Width           =   1815
  75.    End
  76.    Begin VB.CommandButton cmdSetKeyItem 
  77.       Caption         =   "Set Item"
  78.       Height          =   375
  79.       Left            =   5400
  80.       TabIndex        =   18
  81.       Top             =   1680
  82.       Width           =   1815
  83.    End
  84.    Begin VB.CommandButton cmdDeleteKey 
  85.       Caption         =   "Delete Key"
  86.       Height          =   375
  87.       Left            =   5400
  88.       TabIndex        =   15
  89.       Top             =   480
  90.       Width           =   1815
  91.    End
  92.    Begin VB.CommandButton cmdCreateKey 
  93.       Caption         =   "Create Key"
  94.       Height          =   375
  95.       Left            =   5400
  96.       TabIndex        =   14
  97.       Top             =   120
  98.       Width           =   1815
  99.    End
  100.    Begin VB.TextBox txtItemValue 
  101.       Height          =   285
  102.       Left            =   1200
  103.       MultiLine       =   -1  'True
  104.       TabIndex        =   13
  105.       Text            =   "frmRegs5.frx":0000
  106.       Top             =   3240
  107.       Width           =   3975
  108.    End
  109.    Begin VB.Frame Frame1 
  110.       Caption         =   "Data Type"
  111.       Height          =   1215
  112.       Left            =   1200
  113.       TabIndex        =   28
  114.       Top             =   1920
  115.       Width           =   3975
  116.       Begin VB.OptionButton optType 
  117.          Caption         =   "DWord MSB"
  118.          Height          =   255
  119.          Index           =   8
  120.          Left            =   2640
  121.          TabIndex        =   12
  122.          Top             =   800
  123.          Width           =   1215
  124.       End
  125.       Begin VB.OptionButton optType 
  126.          Caption         =   "DWord LSB"
  127.          Height          =   255
  128.          Index           =   7
  129.          Left            =   2640
  130.          TabIndex        =   11
  131.          Top             =   520
  132.          Width           =   1215
  133.       End
  134.       Begin VB.OptionButton optType 
  135.          Caption         =   "Link"
  136.          Height          =   255
  137.          Index           =   6
  138.          Left            =   2640
  139.          TabIndex        =   10
  140.          Top             =   240
  141.          Width           =   1215
  142.       End
  143.       Begin VB.OptionButton optType 
  144.          Caption         =   "Not Defined"
  145.          Height          =   255
  146.          Index           =   5
  147.          Left            =   1080
  148.          TabIndex        =   9
  149.          Top             =   800
  150.          Width           =   1455
  151.       End
  152.       Begin VB.OptionButton optType 
  153.          Caption         =   "Expand String"
  154.          Height          =   255
  155.          Index           =   4
  156.          Left            =   1080
  157.          TabIndex        =   8
  158.          Top             =   520
  159.          Width           =   1455
  160.       End
  161.       Begin VB.OptionButton optType 
  162.          Caption         =   "Multi-line String"
  163.          Height          =   255
  164.          Index           =   3
  165.          Left            =   1080
  166.          TabIndex        =   7
  167.          Top             =   240
  168.          Width           =   1455
  169.       End
  170.       Begin VB.OptionButton optType 
  171.          Caption         =   "Binary"
  172.          Height          =   255
  173.          Index           =   2
  174.          Left            =   120
  175.          TabIndex        =   6
  176.          Top             =   800
  177.          Width           =   975
  178.       End
  179.       Begin VB.OptionButton optType 
  180.          Caption         =   "DWord"
  181.          Height          =   255
  182.          Index           =   1
  183.          Left            =   120
  184.          TabIndex        =   5
  185.          Top             =   520
  186.          Width           =   975
  187.       End
  188.       Begin VB.OptionButton optType 
  189.          Caption         =   "String"
  190.          Height          =   255
  191.          Index           =   0
  192.          Left            =   120
  193.          TabIndex        =   4
  194.          Top             =   240
  195.          Value           =   -1  'True
  196.          Width           =   975
  197.       End
  198.    End
  199.    Begin VB.TextBox txtItemName 
  200.       Height          =   285
  201.       Left            =   1200
  202.       TabIndex        =   3
  203.       Top             =   1560
  204.       Width           =   3975
  205.    End
  206.    Begin VB.TextBox txtSubKey 
  207.       Height          =   285
  208.       Left            =   1200
  209.       TabIndex        =   2
  210.       Top             =   1080
  211.       Width           =   3975
  212.    End
  213.    Begin VB.TextBox txtKey 
  214.       Height          =   285
  215.       Left            =   1200
  216.       TabIndex        =   1
  217.       Text            =   "SOFTWARE\test"
  218.       Top             =   600
  219.       Width           =   3975
  220.    End
  221.    Begin VB.ComboBox cboRoot 
  222.       Height          =   315
  223.       Left            =   1200
  224.       TabIndex        =   0
  225.       Top             =   120
  226.       Width           =   3975
  227.    End
  228.    Begin RegistryControl.RegiCon RegiCon1 
  229.       Left            =   360
  230.       Top             =   2160
  231.       _ExtentX        =   847
  232.       _ExtentY        =   847
  233.    End
  234.    Begin VB.Label Label7 
  235.       Alignment       =   1  'Right Justify
  236.       Caption         =   "Items:"
  237.       Height          =   255
  238.       Left            =   240
  239.       TabIndex        =   30
  240.       Top             =   5280
  241.       Width           =   855
  242.    End
  243.    Begin VB.Label Label6 
  244.       Alignment       =   1  'Right Justify
  245.       Caption         =   "Sub-Keys:"
  246.       Height          =   255
  247.       Left            =   240
  248.       TabIndex        =   29
  249.       Top             =   4080
  250.       Width           =   855
  251.    End
  252.    Begin VB.Label Label5 
  253.       Alignment       =   1  'Right Justify
  254.       Caption         =   "Value:"
  255.       Height          =   255
  256.       Left            =   360
  257.       TabIndex        =   27
  258.       Top             =   3240
  259.       Width           =   735
  260.    End
  261.    Begin VB.Label Label4 
  262.       Alignment       =   1  'Right Justify
  263.       Caption         =   "Item:"
  264.       Height          =   255
  265.       Left            =   120
  266.       TabIndex        =   26
  267.       Top             =   1560
  268.       Width           =   855
  269.    End
  270.    Begin VB.Label Label3 
  271.       Alignment       =   1  'Right Justify
  272.       Caption         =   "Sub-Key:"
  273.       Height          =   255
  274.       Left            =   120
  275.       TabIndex        =   25
  276.       Top             =   1080
  277.       Width           =   975
  278.    End
  279.    Begin VB.Label Label2 
  280.       Alignment       =   1  'Right Justify
  281.       Caption         =   "Key:"
  282.       Height          =   255
  283.       Left            =   240
  284.       TabIndex        =   24
  285.       Top             =   600
  286.       Width           =   855
  287.    End
  288.    Begin VB.Label Label1 
  289.       Alignment       =   1  'Right Justify
  290.       Caption         =   "Root-Key:"
  291.       Height          =   255
  292.       Left            =   120
  293.       TabIndex        =   23
  294.       Top             =   120
  295.       Width           =   975
  296.    End
  297. Attribute VB_Name = "Form1"
  298. Attribute VB_GlobalNameSpace = False
  299. Attribute VB_Creatable = False
  300. Attribute VB_PredeclaredId = True
  301. Attribute VB_Exposed = False
  302. Option Explicit
  303. Private Sub cboRoot_Click()
  304.     '
  305.     'the SubKeyNames() array and ItemNames() array
  306.     'are only valid after an EnumerateEntry method
  307.     'so we clear the list to prevent any confusion
  308.     List1.Clear
  309.     List2.Clear
  310. End Sub
  311. Private Sub cmdCreateKey_Click()
  312.     If Trim$(txtKey.Text) = "" Then
  313.         MsgBox "Must specify a Key", vbInformation, "No Key"
  314.         Exit Sub
  315.     End If
  316.     '
  317.     'When you use the SetEntry method without
  318.     'specifying a KeyItemName, an empty key is created
  319.     'in the registry
  320.     RegiCon1.RootKey = cboRoot.ListIndex
  321.     RegiCon1.Key = txtKey.Text
  322.     RegiCon1.KeyItemName = ""
  323.     RegiCon1.SetEntry
  324.     '
  325.     'the SubKeyNames() array and ItemNames() array
  326.     'are only valid after an EnumerateEntry method
  327.     'so we clear the list to prevent any confusion
  328.     List1.Clear
  329.     List2.Clear
  330. End Sub
  331. Private Sub cmdDeleteKey_Click()
  332.     If Trim$(txtKey.Text) = "" Then
  333.         MsgBox "Must specify a Key", vbInformation, "No Key"
  334.         Exit Sub
  335.     End If
  336.     If txtSubKey.Text = "" Then
  337.         MsgBox "You have chosen to delete a key directly off of a RootKey!" & vbCr & vbCrLf _
  338.             & "Although you can create keys directly off of HKEY_CLASSES_ROOT or HKEY_CURRENT_USER," & vbCrLf _
  339.             & "deleting a key from a root key is NOT normal and this sample will NOT delete this key!" & vbCr & vbCrLf _
  340.             & "Normally you should use the SubKey property to specify which portion of the multikey to delete (see the Help File)." & vbCr & vbCrLf _
  341.             , vbExclamation, "Delete Prevented By Sample!"
  342.         Exit Sub
  343.     Else
  344.         If MsgBox("Are you sure you want to delete the subkey '" & txtSubKey.Text & "' from the key '" & txtKey.Text & "'?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete Key") = vbNo Then
  345.             Exit Sub
  346.         End If
  347.     End If
  348.     '
  349.     'To delete a Key and any of its subkeys and items,
  350.     'set Key to the parent key of the subkey to delete;
  351.     'set the SubKey to the key that you want to delete;
  352.     '
  353.     'To delete an entire key, do NOT specify a KeyItemName, otherwise
  354.     'the control will only delete the item
  355.     RegiCon1.RootKey = cboRoot.ListIndex
  356.     RegiCon1.Key = txtKey.Text
  357.     RegiCon1.SubKey = txtSubKey.Text
  358.     RegiCon1.KeyItemName = ""
  359.     RegiCon1.DeleteEntry
  360.     txtSubKey.Text = ""
  361.     txtItemValue.Text = ""
  362.     '
  363.     'the SubKeyNames() array and ItemNames() array
  364.     'are only valid after an EnumerateEntry method
  365.     'so we clear the list to prevent any confusion
  366.     List1.Clear
  367.     List2.Clear
  368. End Sub
  369. Private Sub cmdDeleteKeyItem_Click()
  370.     If Trim$(txtKey.Text) = "" Then
  371.         MsgBox "Must specify a Key", vbInformation, "No Key"
  372.         Exit Sub
  373.     ElseIf Trim$(txtItemName) = "" Then
  374.         MsgBox "Must specify an Item", vbInformation, "No Item"
  375.         Exit Sub
  376.     End If
  377.     If MsgBox("Are you sure you want to delete the item '" & txtItemName.Text & "'?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete Item") = vbNo Then
  378.         Exit Sub
  379.     End If
  380.     'to delete an item from a key, specify
  381.     'the key and set the KeyItemName to the item
  382.     'that you want to delete
  383.     RegiCon1.RootKey = cboRoot.ListIndex
  384.     RegiCon1.Key = txtKey.Text
  385.     RegiCon1.KeyItemName = txtItemName.Text
  386.     RegiCon1.DeleteEntry
  387.     txtItemName.Text = ""
  388.     txtItemValue.Text = ""
  389.     '
  390.     'the SubKeyNames() array and ItemNames() array
  391.     'are only valid after an EnumerateEntry method
  392.     'so we clear the list to prevent any confusion
  393.     List1.Clear
  394.     List2.Clear
  395. End Sub
  396. Private Sub cmdEnumEntry_Click()
  397.     '
  398.     'clear any previous results
  399.     List1.Clear
  400.     List2.Clear
  401.     RegiCon1.RootKey = cboRoot.ListIndex
  402.     RegiCon1.Key = txtKey.Text
  403.     RegiCon1.KeyItemName = ""
  404.     RegiCon1.EnumerateEntry
  405.     '
  406.     'loop through both arrays, displaying
  407.     'the results
  408.     Dim l As Long
  409.     For l = 0 To RegiCon1.SubKeysCount - 1
  410.         List1.AddItem RegiCon1.SubKeyNames(l)
  411.     Next l
  412.     l = 0
  413.     For l = 0 To RegiCon1.ItemsCount - 1
  414.         List2.AddItem RegiCon1.ItemNames(l)
  415.     Next l
  416. End Sub
  417. Private Sub cmdExit_Click()
  418.     Unload Me
  419. End Sub
  420. Private Sub cmdGetKeyItem_Click()
  421.     Dim str As String
  422.     Dim i As Integer
  423.     txtItemValue.Text = ""
  424.     If Trim$(txtKey.Text) = "" Then
  425.         MsgBox "Must specify a Key", vbInformation, "No Key"
  426.         Exit Sub
  427.     'allow getting the default key
  428.     'ElseIf Trim$(txtItemName) = "" Then
  429.     '    MsgBox "Must specify an Item", vbInformation, "No Item"
  430.     '    Exit Sub
  431.     End If
  432.     '
  433.     'to retrieve an item, specify the
  434.     'Key and KeyItemName, then call the
  435.     'GetEntry method. The KeyItemType and
  436.     'KeyItemValue properties will contain the
  437.     'data type and value, respectively.
  438.     '
  439.     'If unable to open/locate the item, the type
  440.     'will be REG_NONE and the value will be null
  441.     RegiCon1.RootKey = cboRoot.ListIndex
  442.     RegiCon1.Key = txtKey.Text
  443.     RegiCon1.KeyItemName = txtItemName.Text
  444.     RegiCon1.GetEntry
  445.     str = "Value: " & CStr(RegiCon1.KeyItemValue) & vbCr & vbCrLf
  446.     i = RegiCon1.KeyItemType
  447.     Select Case i
  448.         Case dtREG_SZ
  449.             str = str & "Type: REG_SZ"
  450.             optType(0).Value = True
  451.         Case dtREG_DWORD
  452.             str = str & "Type: REG_DWORD"
  453.             optType(1).Value = True
  454.         Case dtREG_BINARY
  455.             str = str & "Type: REG_BINARY"
  456.             optType(2).Value = True
  457.         Case dtREG_MULTI_SZ
  458.             str = str & "Type: REG_MULTI_SZ"
  459.             optType(3).Value = True
  460.         Case dtREG_EXPAND_SZ
  461.             str = str & "Type: REG_EXPAND_SZ"
  462.             optType(4).Value = True
  463.         Case dtREG_NONE
  464.             str = str & "Type: REG_NONE"
  465.             optType(5).Value = True
  466.         Case dtREG_LINK
  467.             str = str & "Type: REG_LINK"
  468.             optType(6).Value = True
  469.         Case dtREG_DWORD_LITTLE_ENDIAN
  470.             'this will never happen because REG_DWORD_LITTLE_ENDIAN
  471.             'and DWord are the same thing.
  472.             str = str & "Type: REG_DWORD_LITTLE_ENDIAN"
  473.             optType(7).Value = True
  474.         Case dtREG_DWORD_BIG_ENDIAN
  475.             str = str & "Type: REG_DWORD_BIG_ENDIAN"
  476.             optType(8).Value = True
  477.         Case Else
  478.             'list is not implemented
  479.             str = str & "Type: Other (" & CStr(i) & ")"
  480.             optType(5).Value = True
  481.     End Select
  482.     txtItemValue.Text = CStr(RegiCon1.KeyItemValue)
  483.     '
  484.     'the SubKeyNames() array and ItemNames() array
  485.     'are only valid after an EnumerateEntry method
  486.     'so we clear the list to prevent any confusion
  487.     List1.Clear
  488.     List2.Clear
  489.     '
  490.     'display the results
  491.     MsgBox str
  492. End Sub
  493. Private Sub cmdIsItem_Click()
  494.     If Trim$(txtKey.Text) = "" Then
  495.         MsgBox "Must specify a Key", vbInformation, "No Key"
  496.         Exit Sub
  497.     ElseIf Trim$(txtItemName) = "" Then
  498.         MsgBox "Must specify an Item", vbInformation, "No Item"
  499.         Exit Sub
  500.     End If
  501.     RegiCon1.RootKey = cboRoot.ListIndex
  502.     RegiCon1.Key = txtKey.Text
  503.     RegiCon1.KeyItemName = txtItemName.Text
  504.         
  505.     If (RegiCon1.IsEntry) Then
  506.         MsgBox "This IS an Item:" & vbCr & vbCrLf & "Key = " & txtKey.Text & vbCrLf & "Item = " & txtItemName
  507.     Else
  508.         MsgBox "This IS NOT an Item:" & vbCr & vbCrLf & "Key = " & txtKey.Text & vbCrLf & "Item = " & txtItemName
  509.     End If
  510.     '
  511.     'the SubKeyNames() array and ItemNames() array
  512.     'are only valid after an EnumerateEntry method
  513.     'so we clear the list to prevent any confusion
  514.     List1.Clear
  515.     List2.Clear
  516. End Sub
  517. Private Sub cmdIsKey_Click()
  518.     If Trim$(txtKey.Text) = "" Then
  519.         MsgBox "Must specify a Key", vbInformation, "No Key"
  520.         Exit Sub
  521.     End If
  522.         
  523.     RegiCon1.RootKey = cboRoot.ListIndex
  524.     RegiCon1.Key = txtKey.Text
  525.     RegiCon1.KeyItemName = ""
  526.         
  527.     If (RegiCon1.IsEntry) Then
  528.         MsgBox "This IS an entry:" & vbCr & vbCrLf & "Key = " & txtKey.Text
  529.     Else
  530.         MsgBox "This IS NOT an entry:" & vbCr & vbCrLf & "Key = " & txtKey.Text
  531.     End If
  532.     '
  533.     'the SubKeyNames() array and ItemNames() array
  534.     'are only valid after an EnumerateEntry method
  535.     'so we clear the list to prevent any confusion
  536.     List1.Clear
  537.     List2.Clear
  538. End Sub
  539. Private Sub cmdSetKeyItem_Click()
  540.     '
  541.     'To set a key item, call the SetEntry
  542.     'method after specifying a Key, KeyItemName,
  543.     'KeyItemType and appropriate KeyItemValue
  544.     If Trim$(txtKey.Text) = "" Then
  545.         MsgBox "Must specify a Key", vbInformation, "No Key"
  546.         Exit Sub
  547.     '
  548.     'allow setting the default key
  549.     'ElseIf Trim$(txtItemName) = "" Then
  550.     '    MsgBox "Must specify an Item", vbInformation, "No Item"
  551.     '    Exit Sub
  552.     End If
  553.     RegiCon1.RootKey = cboRoot.ListIndex
  554.     RegiCon1.Key = txtKey.Text
  555.     RegiCon1.KeyItemName = txtItemName.Text
  556.     RegiCon1.KeyItemValue = txtItemValue.Text
  557.     RegiCon1.SetEntry
  558.     '
  559.     'the SubKeyNames() array and ItemNames() array
  560.     'are only valid after an EnumerateEntry method
  561.     'so we clear the list to prevent any confusion
  562.     List1.Clear
  563.     List2.Clear
  564. End Sub
  565. Private Sub Form_Load()
  566.     Dim TempString As String
  567.     cboRoot.AddItem "HKEY_LOCAL_MACHINE", 0
  568.     cboRoot.AddItem "HKEY_CURRENT_USER", 1
  569.     cboRoot.AddItem "HKEY_CURRENT_CONFIG", 2
  570.     cboRoot.AddItem "HKEY_USERS", 3
  571.     cboRoot.AddItem "HKEY_CLASSES_ROOT", 4
  572.     cboRoot.AddItem "HKEY_DYN_DATA", 5
  573.     cboRoot.ListIndex = 0
  574.     RegiCon1.KeyItemType = 0
  575.     Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
  576.     TempString = "The following sample demonstrates the Mabry RegiCon OCX." & vbCr & vbCrLf & _
  577.                 "When using this sample, you have direct access to your system registry " & _
  578.                 "and you can add, delete, and change the contents of your current registry settings. " & vbCr & vbCrLf & _
  579.                 "You are STRONGLY encouraged to use this sample application " & _
  580.                 "to create some TEST keys and items, then edit and delete the test entries." & vbCr & vbCrLf & _
  581.                 "Further, a thorough understanding of the how the Key and SubKey properties work together to delete " & _
  582.                 "keys is highly recommended."
  583.                 
  584.     MsgBox TempString, vbInformation, "READ ME!"
  585. End Sub
  586. Private Sub List1_Click()
  587.     If List1.ListIndex < 0 Then
  588.         Exit Sub
  589.     End If
  590.     txtItemName.Text = ""
  591.     If txtKey.Text <> "" Then
  592.         txtKey.Text = RegiCon1.Key & "\" & List1.List(List1.ListIndex)
  593.     Else
  594.         txtKey.Text = List1.List(List1.ListIndex)
  595.     End If
  596. End Sub
  597. Private Sub List2_Click()
  598.     If List2.ListIndex < 0 Then
  599.         Exit Sub
  600.     End If
  601.     txtKey.Text = RegiCon1.Key
  602.     txtItemName.Text = List2.List(List2.ListIndex)
  603. End Sub
  604. Private Sub optType_Click(Index As Integer)
  605.     Static i As Integer
  606.     If i = Index Then
  607.         Exit Sub
  608.     End If
  609.     If Index = 2 Or Index = 3 Then
  610.         txtItemValue.Height = 885
  611.     Else
  612.         txtItemValue.Height = 285
  613.     End If
  614.     RegiCon1.KeyItemType = Index
  615.     i = Index
  616.     txtItemValue.Text = ""
  617. End Sub
  618.